--昂扬斗志
local angyangdouzhi = fk.CreateSkill {
    name = "mcdh_angyangdouzhi"
}

local U = require "packages/utility/utility"
local lib = require "packages/mcdh/lib"

angyangdouzhi:addEffect(fk.CardUseFinished,{
    can_trigger = function(self,event,target,player,data)
        return player:hasSkill(self) and data.from == player.id and not data.damageDealt and player:getMark("mcdh_charge") >=2 and
                (data.card.type == Card.TypeBasic or data.card:isCommonTrick())
    end,
    on_cost = function(self,event,target,player,data)
        local room = player.room
        local choices = {"angyangdouzhi1","angyangdouzhi2", "angyangdouzhi-offense","cancel"}
        local card = Fk:cloneCard(data.card.name)
        if not U.getDefaultTargets(player, card, true, false) then
            table.removeOne(choices,"angyangdouzhi2")
        end
        if player:getMark("mcdh_charge") <3 then
            table.removeOne(choices,"angyangdouzhi-offense")
        end
        local choice = room:askForChoice(player, choices, self.name, nil, nil,{"angyangdouzhi1","angyangdouzhi2", "angyangdouzhi-offense","cancel"})
        if choice ~= "cancel" then
            self.cost_data = choice
            return true
        end
    end,
    on_use = function(self,event,target,player,data)
        lib.LoseCharge(player,player,2,self.name)
        local room = player.room
        local card = Fk:cloneCard(data.card.name)
        if self.cost_data == "angyangdouzhi1" or self.cost_data == "angyangdouzhi-offense" then
            player:drawCards(2,self.name)
        end
        if self.cost_data == "angyangdouzhi2" or self.cost_data == "angyangdouzhi-offense" then
            if U.getDefaultTargets(player, card, true, false) then
                U.askForUseVirtualCard(room, player, data.card.name, nil, self.name, nil, false, true, false, true, nil, false)
            end
        end
        if  self.cost_data == "angyangdouzhi-offense" then
            lib.LoseCharge(player,player,1,self.name)
        end
    end
})

Fk:loadTranslationTable {
    ["mcdh_angyangdouzhi"] = "昂扬斗志",
    [":mcdh_angyangdouzhi"] = "蓄力技(2),若你使用的普通锦囊牌或基本牌未造成伤害,此牌结算后,你可以选择一项:1.摸两张牌;2.视为你再次使用此牌;背水:你失去1点技力。",
    ["angyangdouzhi1"] = "1.摸两张牌",
    ["angyangdouzhi2"] = "2.视为你再次使用此牌",
    ["angyangdouzhi-offense"] = "背水:你失去1点技力。"
}

return angyangdouzhi